/**
 * Created by Administrator on 2015/5/11.
 */
var products = {};
/**
 * 初始化产品月
 * @param producttype
 */
function innitMonthProduct(producttype)
{
    $.ajax( {
        type : "post",
        url: "/tools/list_ajax.ashx?act=Astock&productType=" + producttype,
        dataType : 'JSON',
        error : function(a)
        {
            $("#ddw_sel").html("<div style=\"color:gray\">网络异常...</div>");
        },
        success : function(result)
        {
            var product = eval(result["product"]);
            products = eval(result["products"]);
            var ddw_sel_content = "";
            if(product==null||product==""){
                ddw_sel_content="<center><div style=\"color:gray\">暂无产品</div></center>";
            }else
            {
                var defaltmoney = $(".select-btn-active").attr("data-pzamount");
                $("#moneymin").val(products[0]["moneyMin"]);
                $("#moneymax").val(products[0]["moneyMax"]);
                $("#JS-input-amount").attr("placeholder", "最少" + fomatNumber(products[0]["moneyMin"]) + "，最多" + fomatNumber(products[0]["moneyMax"]) + "，百的整数倍");

                $("#errow_title").text("最少" + fomatNumber(products[0]["moneyMin"]) + "，最多" + fomatNumber(products[0]["moneyMax"]) + "，百的整数倍");
              
                var moneyTimes =0;
                for( var i = 0; i < products.length; i++)
                {
                    if(products[i]["moneyTimes"] > moneyTimes)
                    {
                        moneyTimes = products[i]["moneyTimes"];
                        if (i == 0) {
                            ddw_sel_content += ' <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn select-btn-active">';
                        } else {
                            ddw_sel_content += ' <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn ">';
                        }
                        ddw_sel_content += '<div data-mutiple="' + products[i]["moneyTimes"] + '">' + products[i]["moneyTimes"] + '倍</div>';
                        ddw_sel_content += '<div class="monthinterest">月利率：' +toDecimal2( products[i]["moneyRate"]*100) + '%</div>';
                        ddw_sel_content += '<div class="JS-invest-val">' + parseInt(defaltmoney) * parseInt(products[i]["moneyTimes"]) + ' 元</div>';
                        ddw_sel_content += '</div>';
                    }
                }
            }
            $(".last-child").html(ddw_sel_content);


            multipchange();
            checkmoney();
            var _money = getUrlParam("money");
       
            if (_money != "" && _money != null && _money != undefined && _money != '/') {
                rechargeSuccess(_money);
            }
        }
    });
}



var resonproducts = {};
/**
 * 初始化产品季
 * @param producttype
 */
function innitResonProduct(producttype) {
    $.ajax({
        type: "post",
        url: "/tools/list_ajax.ashx?act=Astock&productType=" + producttype,
        dataType: 'JSON',
        error: function (a) {
            $("#ddw_sel").html("<div style=\"color:gray\">网络异常...</div>");
        },
        success: function (result) {
            var product = eval(result["product"]);
            resonproducts = eval(result["products"]);
            var ddw_sel_content = "";
            if (product == null || product == "") {
                ddw_sel_content = "<center><div style=\"color:gray\">暂无产品</div></center>";
            } else {
                var defaltmoney = $(".select-btn-active").attr("data-pzamount");
                $("#moneymin").val(resonproducts[0]["moneyMin"]);
                $("#moneymax").val(resonproducts[0]["moneyMax"]);
                $("#JS-input-amount").attr("placeholder", "最少" + fomatNumber(resonproducts[0]["moneyMin"]) + "，最多" + fomatNumber(resonproducts[0]["moneyMax"]) + "，百的整数倍");

                $("#errow_title").text("最少" + fomatNumber(resonproducts[0]["moneyMin"]) + "，最多" + fomatNumber(resonproducts[0]["moneyMax"]) + "，百的整数倍");

                var moneyTimes = 0;
                for (var i = 0; i < resonproducts.length; i++) {
                    if (resonproducts[i]["moneyTimes"] > moneyTimes) {
                        moneyTimes = resonproducts[i]["moneyTimes"];
                        if (i == 0) {
                            ddw_sel_content += ' <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn select-btn-active">';
                        } else {
                            ddw_sel_content += ' <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn ">';
                        }
                        ddw_sel_content += '<div data-mutiple="' + resonproducts[i]["moneyTimes"] + '">' + resonproducts[i]["moneyTimes"] + '倍</div>';
                        ddw_sel_content += '<div class="monthinterest">月利率：' + toDecimal2(resonproducts[i]["moneyRate"] * 100) + '%</div>';
                        ddw_sel_content += '<div class="JS-invest-val">' + parseInt(defaltmoney) * parseInt(resonproducts[i]["moneyTimes"]) + ' 元</div>';
                        ddw_sel_content += '</div>';
                    }
                }
            }
            $(".last-child").html(ddw_sel_content);


            multipchange();
            checkmoney();
            var _money = getUrlParam("money");

            if (_money != "" && _money != null && _money != undefined && _money != '/') {
                rechargeSuccess(_money);
            }
        }
    });
}



var productfhs = {};
/**
 * 初始化产品互惠
 * @param producttype
 */
function innitReciprocityProduct(producttype) {
    $.ajax({
        type: "post",
        url: "/tools/list_ajax.ashx?act=Astock&productType=" + producttype,
        dataType: 'JSON',
        error: function (a) {
            $("#ddw_sel").html("<div style=\"color:gray\">网络异常...</div>");
        },
        success: function (result) {
            var product = eval(result["product"]);
            productfhs = eval(result["products"]);
            var ddw_sel_content = "";
            if (product == null || product == "") {
                ddw_sel_content = "<center><div style=\"color:gray\">暂无产品</div></center>";
            } else {

                var apply_money = $(".select-btn-active").eq(1).attr("data-pzamount");
                var defaltmoney = 0;
                if (apply_money != "" || apply_money != null || apply_money != undefined) {
                    defaltmoney = apply_money;
                }

                $("#moneymin").val(productfhs[0]["moneyMin"]);
                $("#moneymax").val(productfhs[0]["moneyMax"]);
                $("#JS-input-amount").attr("placeholder", "最少" + fomatNumber(productfhs[0]["moneyMin"]) + "，最多" + fomatNumber(productfhs[0]["moneyMax"]) + "，百的整数倍");

                $("#errow_title").text("最少" + fomatNumber(productfhs[0]["moneyMin"]) + "，最多" + fomatNumber(productfhs[0]["moneyMax"]) + "，百的整数倍");

                var moneyTimes = 0;
                for (var i = 0; i < productfhs.length; i++) {
                    if (productfhs[i]["moneyTimes"] > moneyTimes) {
                        moneyTimes = productfhs[i]["moneyTimes"];
                        if (i == 0) {
                            ddw_sel_content += ' <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn select-btn-active">';
                        } else {
                            ddw_sel_content += ' <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn ">';
                        }
                        ddw_sel_content += '<div data-mutiple="' + productfhs[i]["moneyTimes"] + '">' + productfhs[i]["moneyTimes"] + '倍</div>';
                        //ddw_sel_content += '<div class="monthinterest">月利率：' + toDecimal2(productfhs[i]["moneyRate"] * 100) + '%</div>';
                        ddw_sel_content += '<div class="monthinterest">免息</div>';
                        ddw_sel_content += '<div class="JS-invest-val">' + parseInt(defaltmoney) * parseInt(productfhs[i]["moneyTimes"]) + ' 元</div>';
                        ddw_sel_content += '</div>';
                    }
                }
            }
            $(".last-child").html(ddw_sel_content);


            multipchange();
            checkmoney();
            var _money = getUrlParam("money");

          
            if (_money != "" && _money != null && _money != undefined && _money != '/' && _is == 1) {
                _is = 0;
                rechargeSuccess(_money);
            }
        }
    });
}

var productsjh = {};
/**
 * 初始化产极惠
 * @param producttype
 */
function innitjhProduct(producttype) {
    $.ajax({
        type: "post",
        url: "/tools/list_ajax.ashx?act=Astock&productType=" + producttype,
        dataType: 'JSON',
        error: function (a) {
            $("#ddw_sel").html("<div style=\"color:gray\">网络异常...</div>");
        },
        success: function (result) {
            var product = eval(result["product"]);
            productsjh = eval(result["products"]);
            var ddw_sel_content = "";
            if (product == null || product == "") {
                ddw_sel_content = "<center><div style=\"color:gray\">暂无产品</div></center>";
            } else {
                var defaltmoney = $(".select-btn-active").attr("data-pzamount");
                $("#moneymin").val(productsjh[0]["moneyMin"]);
                $("#moneymax").val(productsjh[0]["moneyMax"]);
                $("#JS-input-amount").attr("placeholder", "最少" + fomatNumber(productsjh[0]["moneyMin"]) + "，最多" + fomatNumber(productsjh[0]["moneyMax"]) + "，百的整数倍");

                $("#errow_title").text("最少" + fomatNumber(productsjh[0]["moneyMin"]) + "，最多" + fomatNumber(productsjh[0]["moneyMax"]) + "，百的整数倍");

                var moneyTimes = 0;
                for (var i = 0; i < productsjh.length; i++) {
                    if (productsjh[i]["moneyTimes"] > moneyTimes) {
                        moneyTimes = productsjh[i]["moneyTimes"];
                        if (i == 0) {
                            ddw_sel_content += ' <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn select-btn-active">';
                        } else {
                            ddw_sel_content += ' <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn ">';
                        }
                        ddw_sel_content += '<div data-mutiple="' + productsjh[i]["moneyTimes"] + '">' + productsjh[i]["moneyTimes"] + '倍</div>';
                        ddw_sel_content += '<div class="monthinterest">月利率：' + toDecimal2(productsjh[i]["moneyRate"] * 100) + '%</div>';
                        ddw_sel_content += '<div class="JS-invest-val">' + parseInt(defaltmoney) * parseInt(productsjh[i]["moneyTimes"]) + ' 元</div>';
                        ddw_sel_content += '</div>';
                    }
                }
            }
            $(".last-child").html(ddw_sel_content);


            multipchange();
            checkmoney();
            var _money = getUrlParam("money");

            if (_money != "" && _money != null && _money != undefined && _money != '/') {
                rechargeSuccess(_money);
            }
        }
    });
}

var productsDay = {};
/**
 * 初始化产品天
 * @param producttype
 */
function innitDayProduct(producttype)
{
    $.ajax( {
        type : "post",
        url: "/tools/list_ajax.ashx?act=Astock&productType=" + producttype,
        dataType : 'JSON',
        error : function(a)
        {
            $(".last-child").html("<div style=\"color:gray\">网络异常...</div>");
        },
        success : function(result)
        {
            var product = eval(result["product"]);
            productsDay = eval(result["products"]);
            var ddw_sel_content = "";
            if(product==null||product==""){
                ddw_sel_content="<center><li style=\"color:gray\">暂无产品</li></center>";
            }else
            {
                var defaltmoney  = $(".select-btn-active").attr("data-pzamount");
            	$("#moneymin").val(product[0]["moneyMin"]);
            	$("#moneymax").val(product[0]["moneyMax"]);
            	$("#JS-input-amount").attr("placeholder", "最少" + fomatNumber(product[0]["moneyMin"]) + "，最多" + fomatNumber(product[0]["moneyMax"]) + "，百的整数倍");
                
            	$("#errow_title").text("最少" + fomatNumber(product[0]["moneyMin"]) + "，最多" + fomatNumber(product[0]["moneyMax"]) + "，百的整数倍");
            	var moneyTimes = "0";
                for( var i = 0; i < productsDay.length; i++)
                {
                    if(productsDay[i]["moneyTimes"] > moneyTimes)
                    {
                        moneyTimes = productsDay[i]["moneyTimes"];
                        if(i==0)
                        {
                            ddw_sel_content += ' <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn select-btn-active">';
                        } else
                        {
                            ddw_sel_content += ' <div id="JS-3" class="JS-trade-investAmount tehui-btn select-btn ">';
                        }
                        ddw_sel_content += '<div data-mutiple="' + productsDay[i]["moneyTimes"] + '">' + productsDay[i]["moneyTimes"] + '倍</div>';
                        ddw_sel_content += '<div class="monthinterest"></div>';
                        ddw_sel_content += '<div class="JS-invest-val">' + parseInt(defaltmoney) *parseInt(productsDay[i]["moneyTimes"]) + ' 元</div>';
                        ddw_sel_content += '</div>';
                    }
                }
            }
            $(".last-child").html(ddw_sel_content);

      
            multipchange();
            checkmoney();
            var _money = getUrlParam("money");

            if (_money != "" && _money != null && _money != undefined && _money != '/') {
                rechargeSuccess(_money);
            }
          
        }
    });
}


var productsWeek = {};
/**
 * 初始化产品周
 * @param producttype
 */
function innitWeekProduct(producttype)
{
    $.ajax( {
        type : "post",
        url: "/tools/list_ajax.ashx?act=Astock&productType=" + producttype,
        dataType : 'JSON',
        error : function(a)
        {
            $("#ddw_sel").html("<div style=\"color:gray\">网络异常...</div>");
        },
        success : function(result)
        {
            var product = eval(result["product"]);
            productsWeek = eval(result["products"]);
            var ddw_sel_content = "";
            var ddw_sel_time = "";
            if(product==null||product==""){
                ddw_sel_content="<center><div style=\"color:gray\">暂无产品</div></center>";
            }else
            {
                $("#capitalMoney").attr("accept",product[0]["moneyMin"]);
                $("#capitalMoney").attr("name",product[0]["moneyMax"]);
                $("#capitalMoney").attr("title","最少"+fomatNumber(product[0]["moneyMin"])+",最多"+fomatNumber(product[0]["moneyMax"]));
                $("#capitalMoney").val("最少"+fomatNumber(product[0]["moneyMin"])+",最多"+fomatNumber(product[0]["moneyMax"]));
                var moneyTimes = 0;
                for( var i = 0; i < productsWeek.length; i++)
                {
                    if(productsWeek[i]["moneyTimes"] > moneyTimes)
                    {
                        moneyTimes = productsWeek[i]["moneyTimes"];
                        if(i==0)
                        {
                            ddw_sel_content = ddw_sel_content + "<li title="+productsWeek[i]["moneyTimes"]+" class=\"curr\" name="+productsWeek[i]["id"]+" onclick=\"checkproduct(this);\"><p class=\"m\"><em>0</em></p><p class=\"p\">"+productsWeek[i]["moneyTimes"]+"倍</p></li>";
                        }else {
                            ddw_sel_content = ddw_sel_content + "<li title=" + productsWeek[i]["moneyTimes"] + " name=" + productsWeek[i]["id"] + " onclick=\"checkproduct(this);\"><p class=\"m\"><em>0</em></p><p class=\"p\">" + productsWeek[i]["moneyTimes"] + "倍</p></li>";
                        }
                    }
                }
            }
            $("#ddw_sel").html(ddw_sel_content);
            $("#days").html(ddw_sel_time)
        }
    });
}


var productsfree = {};
/**
 * 初始化产品免费体验
 * @param producttype
 */
function innitFreeProduct(producttype)
{
    $.ajax( {
        type : "post",
        url: "/tools/list_ajax.ashx?act=Astock&productType=" + producttype,
        dataType : 'JSON',
        error : function(a)
        {
            $("#ddw_sel").html("<div style=\"color:gray\">网络异常...</div>");
        },
        success : function(result)
        {
            var product = eval(result["product"]);
            productsfree = eval(result["products"]);
            if(productsfree.length>0)
            {
                $(".free_borrow").text(productsfree[0]["moneyMin"] * productsfree[0]["moneyTimes"]);
                $(".benjin").text(productsfree[0]["moneyMin"]);
                $(".days").text(productsfree[0]["monthMin"]);
                $(".totalmoney").text(productsfree[0]["moneyMin"] + productsfree[0]["moneyMin"] * productsfree[0]["moneyTimes"]);

                $(".totalborrow").text(productsfree[0]["moneyMin"] * productsfree[0]["moneyTimes"]);

                $(".openline").text((productsfree[0]["moneyMin"] * productsfree[0]["moneyTimes"]* productsfree[0]["rateOpenLine"]).toFixed(2));

              //  $("#leavecount").text(parseInt(productsfree[0]["peopleCount"]) - parseInt($("#avtivityedcount").val()));
                
                if(productsfree[0]["profit_distribution"]==10 || productsfree[0]["profit_distribution"]=="10"){
                    $("#profit_distribution").text(productsfree[0]["profit_distribution"]);
            }else{
                    $("#profit_distribution").text("盈利" + productsfree[0]["profit_distribution"] + "成归您");
                }
                countreplace(parseInt(productsfree[0]["count"]), parseInt(productsfree[0]["peopleCount"]));
            }
        }
    });
}


/**
 * 查询配资列表
 * @param pageIndex 当前页
 * @param size      每页大小
 * @param productType 项目类型
 * @param begintime   开始时间
 * @param endtime     结束时间
 */
function getstockList(pageIndex,size,productType,begintime,endtime){
    $.ajax( {
        type : "post",
        async: false,
        data:{"pageSize":size,"pageIndex":pageIndex,"productType":productType,"begintime":begintime,"endtime":endtime},
        url : "/account/account!ajaxGetstockList.action",
        dataType : 'JSON',
        success : function(result) {
            var resultdiv="<tr><th>产品类型</th><th>配资金额</th><th>保证金</th><th>利率</th><th>配资时间</th><th>到期时间</th><th>状态</th><th  class=\"th1\">操作</th></tr>";
            var rs=eval(result)["rows"];
            if(rs.length > 0){
                for(var i=0;i<rs.length;i++)
                {
                    resultdiv+="<tr><td>"+rs[i]["productCode"]+"</td>"+
                        "<td>"+rs[i]["moneyBorrow"]+"</td>"+
                        "<td>"+rs[i]["moneyDeposit"]+"</td>"+
                        "<td>"+rs[i]["moneyRate"]+"</td>"+
                        "<td>"+rs[i]["moneyBegin"]+"</td>"+
                        "<td>"+rs[i]["moneyEnd"]+"</td>"+
                        "<td style=\"color:#349cd8\">"+stockstatus[rs[i]["status"]]+"</td>"+
                        "<td>"+"<a target=\"_blank\" onclick=\"return linkClick(this.href);\" href=\""+"/stock/stock!stockdetails.action?id="+rs[i]["id"]+"\">查看</a>"+"</td>"+
                        "</tr>";
                }
            }
            else{
                resultdiv+="<tr><td colspan='8'>暂无记录</td></tr>";
            }
            $("#ajaxGetstockList").html(resultdiv);
            var total=eval(result)["total"]; //总共有多少条数据
            var currentPage=eval(result)["currentPage"]; //总共有几页
            var pageindex=eval(result)["pageindex"];     //第几页

            $("#total").text(total);
            $("#currentPage").text(currentPage);
            $("#pageindex").text(pageindex);
        }
    });
}


var productFutures = {};
/**
 * 初始化产品期货
 * @param producttype
 */
function innitFuturesProduct(producttype)
{
    $.ajax( {
        type : "post",
        url: "/tools/list_ajax.ashx?act=Astock&productType=" + producttype,
        dataType : 'JSON',
        error : function(a)
        {
            $("#ddw_sel").html("<div style=\"color:gray\">网络异常...</div>");
        },
        success : function(result)
        {
            var product = eval(result["product"]);
            productFutures = eval(result["products"]);
            var ddw_sel_content = "";
            if(product==null||product==""){
                ddw_sel_content="<center><div style=\"color:gray\">暂无产品</div></center>";
            }else
            {
                $("#capitalMoney").attr("accept",product[0]["moneyMin"]);
                $("#capitalMoney").attr("name",product[0]["moneyMax"]);
                $("#capitalMoney").attr("title","最少"+fomatNumber(product[0]["moneyMin"])+",最多"+fomatNumber(product[0]["moneyMax"]));
                /*$("#capitalMoney").val("最少"+fomatNumber(product[0]["moneyMin"])+",最多"+fomatNumber(product[0]["moneyMax"]));*/
                $("#moneylimit").text(product[0]["moneyMin"]+"-"+fomatNumber(product[0]["moneyMax"]));
                var moneyTimes ="0";
                for( var i = 0; i < productFutures.length; i++)
                {
                        if(productFutures[i]["moneyTimes"] > moneyTimes)
                        {
                            moneyTimes = productFutures[i]["moneyTimes"];
                            if(i==0)
                            {
                                ddw_sel_content = ddw_sel_content + "<li title="+productFutures[i]["moneyTimes"]+" class=\"curr\" name="+productFutures[i]["id"]+" onclick=\"checkproduct(this);\"><p><span>"+productFutures[i]["moneyTimes"]+"倍</span>配资资金</p><p><i>0</i>元</p></li>";
                            }else {
                                ddw_sel_content = ddw_sel_content + "<li title=" + productFutures[i]["moneyTimes"] + " name=" + productFutures[i]["id"] + " onclick=\"checkproduct(this);\"><p><span>"+productFutures[i]["moneyTimes"]+"倍</span>配资资金</p><p><i>0</i>元</p></li>";
                            }
                        }
                }
            }
            $("#ddw_sel").html(ddw_sel_content);
        }
    });
}

var productStock = {};
/**
 * 初始化产品股指宝
 * @param producttype
 */
/*function innitProductStock(producttype)
{
    $.ajax( {
        type : "post",
        url: "/tools/list_ajax.ashx?act=Astock&productType=" + producttype,
        dataType : 'JSON',
        error : function(a)
        {
            $("#ddw_sel").html("<div style=\"color:gray\">网络异常...</div>");
        },
        success : function(result)
        {
            var product = eval(result["product"]);
            productStock = eval(result["products"]);
            var ddw_sel_content = "";
            var stockmin = "";
            if(productStock==null||productStock==""){
                ddw_sel_content="<center><div style=\"color:gray\">暂无产品</div></center>";
            }else
            {
                for( var i = 0; i < productStock.length; i++)
                {
                    if(productStock[i]["flag"]==1)
                    {
                        ddw_sel_content = ddw_sel_content + "<li title='" + productStock[i]["moneyTimes"] +"' onclick=\"checkproduct(this);\">"
                            + "<p class='m'><span>" + productStock[i]["moneyTimes"] + "手</span></p><p class='p'>股指合约</p><div class='b'></div></li>";
                    }
                }
            }
            if(product==null||product==""){
                stockmin = "<center><div style=\"color:gray\">暂无产品</div></center>"
            }
            else{
                for(var i= 0;i< product.length; i++){
                    if(i==0){
                        stockmin = stockmin+ "<li onclick='checkTimes(this)' title='"+product[i]["moneyTimes"]+"'class='curr'>"
                            + "<p class='m' name='"+product[i]["moneyMin"]+"'><span>"+product[i]["moneyMin"]+"</span>元</p>"
                            + "<div class='b'></div>"
                            +"</li>"
                    }
                    else{
                        stockmin +=  "<li onclick='checkTimes(this)' title='"+product[i]["moneyTimes"]+"'>";
                            if(product[i]["moneyTimes"] == 2){
                                stockmin +="<p class='m' name='"+product[i]["moneyMin"]+"'><span>"+product[i]["moneyMin"]+"</span>元</p>";
                            }
                           else{
                                stockmin +="<p class='m' name='"+product[i]["moneyMin"]+"'><span>"+product[i]["moneyMin"]+"</span>元</p>";
                            }
                        stockmin +=  "<div class='b'></div></li>";
                    }
                }
            }
            ddw_sel_content += "<span class='clear_f'></span>";
            stockmin += "<span class='clear_f'></span>";
            $("#ddw_sel").html(ddw_sel_content);
            $("#stockmin").html(stockmin);
        }
    });
}*/
function innitProductStock(producttype)
{
    $.ajax( {
        type : "post",
        url: "/tools/list_ajax.ashx?act=Astock&productType=" + producttype,
        dataType : 'JSON',
        error : function(a)
        {
            $("#ddw_sel").html("<div style=\"color:gray\">网络异常...</div>");
        },
        success : function(result)
        {
            var product = eval(result["product"]);
            productStock = eval(result["products"]);
            var ddw_sel_content = "";
            var stockmin = "";
            if(productStock==null||productStock==""){
                ddw_sel_content="<center><div style=\"color:gray\">暂无产品</div></center>";
            }else
            {
                for( var i = 0; i < productStock.length; i++)
                {
                    if(productStock[i]["flag"]==4)
                    {
                        ddw_sel_content += "<input type='text' id='capacity' class='input' onkeyup='checkproduct(this)'/> <span class='s'>手</span>";
                        $("#productId").val(productStock[i]["id"]);
                    }
                }
            }
            if(product==null||product==""){
                stockmin = "<center><div style=\"color:gray\">暂无产品</div></center>"
            }
            else{
                for(var i= 0;i< product.length; i++){
                    if(i==0){
                        stockmin = stockmin+ "<li title='"+product[i]["moneyTimes"]+"'class='curr'>"
                            + "<p class='m' name='"+product[i]["moneyMin"]+"'><span>"+product[i]["moneyMin"]+"</span>元</p>"
                            + "<div class='b'></div>"
                            +"</li>"
                    }
                    /*else{
                        stockmin +=  "<li title='"+product[i]["moneyTimes"]+"'>";
                        if(product[i]["moneyTimes"] == 2){
                            stockmin +="<p class='m' name='"+product[i]["moneyMin"]+"'><span>"+product[i]["moneyMin"]+"</span>元</p>";
                        }
                        else{
                            stockmin +="<p class='m' name='"+product[i]["moneyMin"]+"'><span>"+product[i]["moneyMin"]+"</span>元</p>";
                        }
                        stockmin +=  "<div class='b'></div></li>";
                    }*/
                }
            }
            ddw_sel_content += "<span class='clear_f'></span>";
            stockmin += "<span class='clear_f'></span>";
            $("#ddw_sel").html(ddw_sel_content);
            $("#stockmin").html(stockmin);
        }
    });
}

var productHszs = {};
function innitProductHszs(producttype)
{
    $.ajax( {
        type : "post",
        url: "/tools/list_ajax.ashx?act=Astock&productType=" + producttype,
        dataType : 'JSON',
        error : function(a)
        {
            $("#ddw_sel").html("<div style=\"color:gray\">网络异常...</div>");
        },
        success : function(result)
        {
            var product = eval(result["product"]);
            productHszs = eval(result["products"]);
            var ddw_sel_content = "";
            var stockmin = "";
            if(productHszs==null||productHszs==""){
                ddw_sel_content="<center><div style=\"color:gray\">暂无产品</div></center>";
            }else
            {
                for( var i = 0; i < productHszs.length; i++)
                {
                    if(productHszs[i]["flag"]==4)
                    {
                        ddw_sel_content += "<input type='text' id='capacity' class='input' onkeyup='checkproduct(this)'/> <span class='s'>手</span>";
                        $("#productId").val(productHszs[i]["id"]);
                    }
                }
            }
            if(product==null||product==""){
                stockmin = "<center><div style=\"color:gray\">暂无产品</div></center>"
            }
            else{
                for(var i= 0;i< product.length; i++){
                    if(i==0){
                        stockmin = stockmin+ "<li title='"+product[i]["moneyTimes"]+"'class='curr'>"
                            + "<p class='m' name='"+product[i]["moneyMin"]+"'><span>"+product[i]["moneyMin"]+"</span>元</p>"
                            + "<div class='b'></div>"
                            +"</li>"
                    }
                }
            }
            ddw_sel_content += "<span class='clear_f'></span>";
            stockmin += "<span class='clear_f'></span>";
            $("#ddw_sel").html(ddw_sel_content);
            $("#stockmin").html(stockmin);
        }
    });
}
/**
 * 获取最新配资动态
 * @param pageIndex
 * @param type
 * @param pageSize
 */
function getUserBorrowHot(pageIndex,type,pageSize,id){
    $.ajax({
        type: "post",
        url: "/stock/stock!getUserBorrowHot.action?pageIndex=" + pageIndex + "&type=" + type + "&pageSize=" + pageSize,
        dataType: 'JSON',
        success: function (result) {
            result = eval(result);
            var stocks = result["rows"];
            var resultdiv = "";
            resultdiv += "<tr><th>申请人</th><th>保证金(元)</th><th>配资金额(元)</th><th>配资周期</th><th>申请时间</th></tr>"
            for (var i = 0; i < stocks.length; i++) {
                if(type == "2" || type == "6"){
                    resultdiv += " <tr>"
                        +   "<td>"+stocks[i].id+"</td><td>￥"+fMoney(stocks[i].moneyDeposit)+"</td><td>￥"+fMoney(stocks[i].moneyBorrow)+"</td><td>"+stocks[i].borrowDays+"个月</td><td>"+new Date(stocks[i]["moneyTime"]).Format("yyyy-MM-dd hh:mm:ss")+"</td>"
                        +   "</tr>"
                }
                else{
                    resultdiv += " <tr>"
                        +   "<td>"+stocks[i].id+"</td><td>￥"+fMoney(stocks[i].moneyDeposit)+"</td><td>￥"+fMoney(stocks[i].moneyBorrow)+"</td><td>"+stocks[i].borrowDays+"天</td><td>"+new Date(stocks[i]["moneyTime"]).Format("yyyy-MM-dd hh:mm:ss")+"</td>"
                        +   "</tr>"
                }
            }
            $("#"+id).html(resultdiv);
        }
    });
}

function rechargeSuccess(money) {

    

    var istrue = $(".select-btn-group-wrap").find("[data-pzamount='" + money + "']").length;

    if (istrue == 0) {
        $(".select-btn-group-wrap").find("[data-pzamount='otherApplyAmount']").trigger("click");

        $("#JS-input-amount").val(money);


        inputaplmochange($("#JS-input-amount"));


    } else {

        $(".select-btn-group-wrap").find("[data-pzamount='" + money + "']").trigger("click");
    }

    $("#JS-instant-apply").trigger("click");
}


function recharge() {

    var _is = location.href.lastIndexOf("?");
    var url = "";
    if (_is == "-1" || _is == -1) {
         url = encodeURIComponent(location.href+ "?money=" + $("#benjin").text());
    } else {
         url = encodeURIComponent(location.href.substring(0, location.href.lastIndexOf("?")) + "?money=" + $("#benjin").text());
    }

  
    location.href = '/member/recharge.html?url=' + url;
}